Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@types/big.js
Advanced tools
TypeScript definitions for big.js
@types/big.js provides TypeScript type definitions for the big.js library, which is used for arbitrary-precision decimal arithmetic in JavaScript.
Basic Arithmetic Operations
This feature allows you to perform basic arithmetic operations such as addition, subtraction, multiplication, and division with arbitrary precision.
const Big = require('big.js');
const a = new Big(0.1);
const b = new Big(0.2);
const sum = a.plus(b); // 0.3
const difference = a.minus(b); // -0.1
const product = a.times(b); // 0.02
const quotient = a.div(b); // 0.5
Comparison Operations
This feature allows you to compare two Big numbers using methods like eq (equal), gt (greater than), and lt (less than).
const Big = require('big.js');
const a = new Big(0.1);
const b = new Big(0.2);
const isEqual = a.eq(b); // false
const isGreaterThan = a.gt(b); // false
const isLessThan = a.lt(b); // true
Rounding
This feature allows you to round a Big number to a specified number of decimal places.
const Big = require('big.js');
const a = new Big(1.2345);
const rounded = a.round(2); // 1.23
Conversion to String
This feature allows you to convert a Big number to a string representation.
const Big = require('big.js');
const a = new Big(1.2345);
const str = a.toString(); // '1.2345'
decimal.js is another library for arbitrary-precision decimal arithmetic. It offers more features compared to big.js, such as support for complex mathematical functions and configuration options for precision and rounding.
bignumber.js is a library for arbitrary-precision arithmetic with a focus on performance. It provides similar functionality to big.js but is optimized for speed and efficiency.
mathjs is a comprehensive mathematics library that includes support for arbitrary-precision arithmetic along with a wide range of other mathematical functions and utilities. It is more feature-rich compared to big.js but also larger in size.
npm install --save @types/big.js
This package contains type definitions for big.js (https://github.com/MikeMcl/big.js/).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/big.js
Additional Details
These definitions were written by Steve Ognibene https://github.com/nycdotnet, Miika Hänninen https://github.com/googol.
FAQs
TypeScript definitions for big.js
The npm package @types/big.js receives a total of 566,802 weekly downloads. As such, @types/big.js popularity was classified as popular.
We found that @types/big.js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.